package org.example.controller;

import cn.hutool.core.util.RandomUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @author shenguangyang
 */
@RestController
@RequestMapping("/alarm")
public class AlarmTestController {
    /**
     * 测试告警
     */
    @GetMapping("/test")
    public String test() throws InterruptedException {
        if (RandomUtil.randomInt(0, 100) > 20) {
            throw new RuntimeException("error");
        }
        if (RandomUtil.randomInt(0, 100) < 20) {
            TimeUnit.SECONDS.sleep(1);
        }
        return UUID.randomUUID().toString();
    }
}
